<?php

class m131116_071902_oak extends CDbMigration
{
    public function safeUp()
    {
        $sql = 'LOAD DATA LOCAL INFILE "%s"
                INTO TABLE `{{city}}`
                CHARACTER SET UTF8
                FIELDS TERMINATED BY "," ENCLOSED BY "\""
                LINES TERMINATED BY "\r\n"
                IGNORE 1 LINES
                (`id`,`name`,`latitude`,`longitude`,`country`,`country_name`)
                SET created_at = NOW(), updated_at = NOW();';
        $sql = sprintf($sql, str_replace('\\', '/', Yii::getPathOfAlias('application.data').'/city.csv'));

        $this->execute($sql);
    }

    public function safeDown()
    {
        return false;
    }
}